﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ImageGallery.ascx.cs"
    Inherits="Controls_ImageGallery" %>
<script src="<%= KTFrameworkCus.Globals.ApplicationPath %>dms/jsWatermark/jquery.data.js"
    type="text/javascript"></script>
<script src="<%= KTFrameworkCus.Globals.ApplicationPath %>dms/jsWatermark/jquery.watermark.min.js"
    type="text/javascript"></script>
<script src="<%= KTFrameworkCus.Globals.ApplicationPath %>dms/jsWatermark/jquery.watermark.js"
    type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#<%= txttitle.ClientID %>").watermark("Tên danh mục...", "watermark2");
        $("#<%= txttitle_en.ClientID %>").watermark("Category name...", "watermark2");
        $("#<%= txttenalbum.ClientID %>").watermark("Tên Album...", "watermark2");
        $("#<%= txttenalbum_en.ClientID %>").watermark("Album name...", "watermark2");
        $("#<%= txtmota.ClientID %>").watermark("Mô tả...", "watermark2");
        $("#<%= txtmota_en.ClientID %>").watermark("Description...", "watermark2");
    });
</script>
<div class="dmsGallery-container">
    <div class="loading">
        <img src="<%= KTFrameworkCus.Globals.ApplicationPath %>dms/loader.gif" alt="Loading" />
        Loading...</div>
    <asp:Panel ID="Albums" runat="server">
        <script type="text/javascript">
            $(document).ready(function () {
                $('.dms-Album-Link').hover(function () {
                    $(this).css('border', 'solid 1px #8FD2FF');
                    $(this).children('span').css('border', 'solid 1px #8FD2FF');
                    $(this).parent().parent().children('.AlbumInsideControl').show();
                }, function () {
                    $(this).css('border', 'solid 1px #E6E6E6');
                    $(this).children('span').css('border', 'solid 1px #E6E6E6');
                    $(this).parent().parent().children('.AlbumInsideControl').hide();
                });
                $(".AlbumInsideControl").hover(function () {
                    $(this).show();
                }, function () {
                    $(this).hide();
                });
            });
        </script>
        <script type="text/javascript">
            $(function () {
                $('#sortable').sortable({
                    placeholder: 'ui-state-highlight',
                    update: OnSortableUpdate
                });
                $('#sortable').disableSelection();

                var progressMessage = 'Saving changes... <img src="dms/loader.gif"/>';
                var successMessage = 'Saved successfully!';
                var errorMessage = 'There was some error in processing your request';
                var messageContainer = $('#message').find('p');

                function OnSortableUpdate(event, ui) {
                    var order = $('#sortable').sortable('toArray').join(',').replace(/id_/gi, '')
                    //console.info(order);

                    $(".loading").show();

                    $.ajax({
                        type: 'POST',
                        url: '<%= KTFrameworkCus.Globals.ApplicationPath %>dms/Ajax/ReOrder.asmx/update',
                        data: '{itemOrder: \'' + order + '\'}',
                        contentType: 'application/json; charset=utf-8',
                        dataType: 'json',
                        success: OnSortableUpdateSuccess,
                        error: OnSortableUpdateError
                    });
                }

                function OnSortableUpdateSuccess(response) {
                    $(".loading").hide();
                }

                function OnSortableUpdateError(xhr, ajaxOptions, thrownError) {

                }

            });
 
        </script>
        <div class="dms-Gallery-Albums-List">
            <ul class="dms-Album-list" id="sortable">
                <asp:Repeater ID="dtlAlbums" runat="server">
                    <ItemTemplate>
                        <li id='dmsAlbumID-<%# Eval("id") %>' class="dms-Album-Poster ui-state-default">
                            <div class="AlbumInsideControl">
                                <asp:LinkButton ID="lnkEdit" runat="server" CommandArgument='<%# Eval("id") %>' CommandName='view'
                                    OnCommand="lnkEdit_Command">Sửa</asp:LinkButton>
                                <asp:LinkButton ID="lnkDelete" runat="server" CommandArgument='<%# Eval("id") %>'
                                    CommandName='delete' OnCommand="lnkDelete_Command" OnClientClick="return confirm('Tất cả các Hình trong Album này cũng sẽ bị xóa theo. Bạn chắc chứ?')">Xóa</asp:LinkButton>
                            </div>
                            <div class="dms-Album-wrapper">
                                <a href='<%= KTFrameworkCus.Globals.ApplicationPath %>webmaster/gallery/detail.aspx?aid=<%# Eval("id") %>'
                                    class="dms-Album-Link"><span><span style='background: url(<%= KTFrameworkCus.Globals.ApplicationPath %>dms/Albums/<%# Eval("imageurl") %>) 0 0;'>
                                    </span></span></a><a href='<%= KTFrameworkCus.Globals.ApplicationPath %>webmaster/gallery/detail.aspx?aid=<%# Eval("id") %>'>
                                        <%# Eval("title")%></a>
                                <div style="color: #C9C9C9; font-size: 12px;">
                                    <%# countImageInAlbum(Eval("id").ToString()) %>
                                    ảnh</div>
                                    <div style="color:#555555;">[<%# Eval("Category")%>]</div>
                            </div>
                        </li>
                    </ItemTemplate>
                </asp:Repeater>
            </ul>
        </div>
    </asp:Panel>
    <div class="dms-Gallery-Control">
        <table width="420px" style="float: left;">
            <tr>
                <td>
                    <asp:FileUpload ID="PhotoFile" runat="server" />
                    <br />
                    <asp:HiddenField ID="HiddenField1" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="txttenalbum" runat="server" Width="390px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txttenalbum"
                        ErrorMessage="RequiredFieldValidator" ForeColor="Red" ValidationGroup="aa">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="txttenalbum_en" runat="server" Width="390px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txttenalbum"
                        ErrorMessage="RequiredFieldValidator" ForeColor="Red" ValidationGroup="aa">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="txtmota" runat="server" Width="390px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="txtmota_en" runat="server" Width="390px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:DropDownList ID="ddldanhmuc" runat="server" Width="390px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:LinkButton ID="btnAddAlbum" Style="display: block; height: 30px; padding: 0 20px;
                        -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #000000;
                        border: solid 1px #BFBFBF; float: left; line-height: 30px; margin-right: 10px;"
                        runat="server" OnClick="btnAddAlbum_Click" ValidationGroup="aa">Thêm mới</asp:LinkButton>
                    <asp:LinkButton ID="btnCancel" Style="display: block; height: 30px; padding: 0 20px;
                        -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #000000;
                        border: solid 1px #BFBFBF; float: left; line-height: 30px;" runat="server" OnClick="btnCancel_Click"
                        Visible="False">Quay về</asp:LinkButton>
                    <p style="clear: both;">
                        <asp:Image ID="Image1" runat="server" /></p>
                </td>
            </tr>
        </table>
        <div style="float: left; width: 365px;">
            <h4>
                Danh mục</h4>
            <div style="width: 365px; height: 98px; overflow: auto;">
                <asp:Repeater ID="rptDanhMuc" runat="server">
                    <ItemTemplate>
                        <div style="position: relative; border: solid 1px #999999; padding: 5px; margin-bottom: 3px; border-radius:3px;">
                            <%# Eval("Title") %>
                            <asp:LinkButton ID="lnkCategoryEdit" Style="position: absolute; right: 20px;" runat="server"
                                CommandArgument='<%# Eval("CateID") %>' CommandName='view' OnCommand="lnkCategoryEdit_Command"><img alt="" src='<%= KTFrameworkCus.Globals.ApplicationPath %>images/edit.png' /></asp:LinkButton>
                            <asp:LinkButton ID="lnkCategoryDelete" Style="position: absolute; right: 4px;" runat="server"
                                CommandArgument='<%# Eval("CateID") %>' CommandName='delete' OnCommand="lnkCategoryDelete_Command"
                                OnClientClick="return confirm('Bạn muốn xóa danh mục này chứ?')"><img alt="" src='<%= KTFrameworkCus.Globals.ApplicationPath %>images/remove-row.gif' /></asp:LinkButton>
                        </div>
                    </ItemTemplate>
                </asp:Repeater>
            </div>
            <asp:TextBox ID="txttitle" runat="server" Width="340px" style="margin-top:5px;"></asp:TextBox><asp:RequiredFieldValidator
                ID="RequiredFieldValidator3" runat="server" ErrorMessage="RequiredFieldValidator"
                ControlToValidate="txttitle" Text="*" ValidationGroup="bb"></asp:RequiredFieldValidator>
            <asp:TextBox ID="txttitle_en" runat="server" Width="340px" Style="margin: 3px 0;"></asp:TextBox><asp:RequiredFieldValidator
                ID="RequiredFieldValidator4" runat="server" ErrorMessage="RequiredFieldValidator"
                ControlToValidate="txttitle_en" Text="*" ValidationGroup="bb"></asp:RequiredFieldValidator>
            <asp:TextBox ID="txtthutu" runat="server" Width="340px" Style="margin: 3px 0;"></asp:TextBox><asp:RegularExpressionValidator
                ID="RegularExpressionValidator1" runat="server" ErrorMessage="RegularExpressionValidator"
                ControlToValidate="txtthutu" Text="*" ValidationGroup="bb" ValidationExpression="\d+"></asp:RegularExpressionValidator>
            <asp:LinkButton ID="btnCategoryAdd" Style="display: block; height: 30px; padding: 0 20px;
                -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #000000;
                border: solid 1px #BFBFBF; float: left; line-height: 30px; margin-right: 10px;"
                runat="server" ValidationGroup="bb" onclick="btnCategoryAdd_Click">Thêm</asp:LinkButton>
            <asp:LinkButton ID="btnCategoryCancel" Style="display: block; height: 30px; padding: 0 20px;
                -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #000000;
                border: solid 1px #BFBFBF; float: left; line-height: 30px;" runat="server" 
                Visible="False" onclick="btnCategoryCancel_Click">Quay về</asp:LinkButton>
            <div style="clear: both;">
            </div>
        </div>
    </div>
</div>
